package com.lian.pet.controller;

import com.lian.pet.common.basic.response.AppResp;
import com.lian.pet.domain.dto.AddPetVaccinesDTO;
import com.lian.pet.domain.dto.QueryPetVaccinesDTO;
import com.lian.pet.domain.vo.PetVaccinesVO;
import com.lian.pet.service.PetVaccinesService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("petvaccines")
@RestController
@AllArgsConstructor
public class PetVaccinesController {
    private final PetVaccinesService petVaccinesService;

    /**
     * 新增宠物接种疫苗记录
     * @param req
     * @param petId
     */
    @PostMapping("/add")
    public AppResp<Void> addpetVaccines(@RequestBody AddPetVaccinesDTO req, @RequestParam("petId") Integer petId) {
        petVaccinesService.addPetVaccines(req, petId);
        return AppResp.succeed(null);
    }

    /**
     * 查询宠物接种疫苗记录列表
     * @param req
     * @param petId
     * @return
     */
    @PostMapping("/queryList")
    public AppResp<List<PetVaccinesVO>> queryPetVaccines(@RequestBody QueryPetVaccinesDTO req, @RequestParam("petId") Integer petId) {
        return AppResp.succeed(petVaccinesService.queryPetVaccines(req, petId));
    }

    /**
     * 查询宠物接种疫苗记录信息
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public AppResp<PetVaccinesVO> getpetVaccinesById(@RequestParam("id") Integer id) {
        return AppResp.succeed(petVaccinesService.getPetVaccines(id));
    }

    /**
     * 删除宠物接种疫苗记录信息
     * @param id
     */
    @GetMapping("/deleteById")
    public AppResp<Integer> deleteById(@RequestParam("id") Integer id) {
        petVaccinesService.deletePetVaccines(id);
        return AppResp.succeed(1);
    }
}
